/**
 * 
 */
package com.alessandrodonato.elledia.model;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;

/**
 * @author Alessandro Donato
 *
 * 18/feb/2013
 */

/*
@Entity annotation is used to declare the POJO as persistent entity.
@Table annotation is used to map the POJO class to the table. In our case it is 'certificato' table in database.
@Id represents the identifier property.
@GeneratedValue declares that the identifier value will be generated by the database automatically. 
@Column is used to map the property to the column of the table.
*/

@Entity
@Table	(name = "materiali", catalog = "elledia", 
			uniqueConstraints = {
					@UniqueConstraint(columnNames = "ID")})
public class Materiale implements Serializable {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = -293429662903271890L;
	private int id;
	private String colata;
	private String dimensione;
	private String unitaMisura;
	private String specificaMateriale;
	private String tipoMateriale;
	private Certificato certificato;
	
	@Id
	@GeneratedValue (strategy = GenerationType.IDENTITY)
	@Column (name = "id", nullable=false, unique=true)
	public int getId() {
		return id;
	}
	public void setId(int id) {
		this.id = id;
	}
	
	@Column (name="colata")
	public String getColata() {
		return colata;
	}
	public void setColata(String colata) {
		this.colata = colata;
	}
	
	@Column (name = "dimensione")
	public String getDimensione() {
		return dimensione;
	}
	public void setDimensione(String dimensione) {
		this.dimensione = dimensione;
	}
	
	@Column (name ="unita_misura")
	public String getUnitaMisura() {
		return unitaMisura;
	}
	public void setUnitaMisura(String unitaMisura) {
		this.unitaMisura = unitaMisura;
	}
	
	@Column (name = "specifica")
	public String getSpecificaMateriale() {
		return specificaMateriale;
	}
	public void setSpecificaMateriale(String specificaMateriale) {
		this.specificaMateriale = specificaMateriale;
	}

	public String getTipoMateriale() {
		return tipoMateriale;
	}
	public void setTipoMateriale(String tipoMateriale) {
		this.tipoMateriale = tipoMateriale;
	}
	
	@ManyToOne
	@Column (name = "certificato_id")
	public Certificato getCertificato() {
		return certificato;
	}
	public void setCertificato(Certificato certificato) {
		this.certificato = certificato;
	}
	
	@Override
	public String toString () {
		return "Materiale [id = " + id + ", unita misura = " + unitaMisura + ", dimensione = " + dimensione + 
				", specifica materiale = " + specificaMateriale + "]";
	}
	
}
